package com.summer.web.v1.base.db;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.summer.web.v1.enums.DerByEnums;

import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

@Deprecated
public class SummerDatasource {

    public final static String NAME = SummerDatasource.class.getName();

    static Logger logger = Logger.getLogger(NAME);

    public static DataSource createDataSource() {
        Map<String, String> map = new HashMap<>();
        map.put(DruidDataSourceFactory.PROP_DRIVERCLASSNAME, "org.apache.derby.jdbc.EmbeddedDriver");
        map.put(DruidDataSourceFactory.PROP_URL, DerByEnums.CONNECTION.sql);
        map.put(DruidDataSourceFactory.PROP_USERNAME, "");
        map.put(DruidDataSourceFactory.PROP_PASSWORD, "");
        try {
            return DruidDataSourceFactory.createDataSource(map);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "创建数据库连接池失败");
        }
        return null;
    }
}
